

set<string> parserPlist(const char* plistname){
  set<string> spriteNames;
  const char *path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plistname);
  CCDictionary *dict = CCDictionary::createWithContentsOfFile(path);
  CCDictionary *frames = (CCDictionary*)dict->objectForKey("frames");
  CCArray *keys = frames->allKeys();
  for(int i=0; i<keys->count(); i++){
    const char * key = ((CCString*)keys->objectAtIndex(i))->getCString();
    CCLog("key %s", key);
    spriteNames.insert(key);
  }
  return spriteNames;  
}

CCAction* createActionFromPlist(const char* plistname){
  CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(plistname);
  set<string> spriteNames = parserPlist(plistname);
  if(spriteNames.empty()){
    return;
  }

  CCArray* arr = CCArray::create();
  set<string>::iterator it = spriteNames.begin();
  for(; it!=spriteNames.end(); ++it){
    string name = (*it).c_str();
    CCLog("key %s", name.c_str());
    CCSpriteFrame *sf = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name.c_str());
    arr->addObject(sf);
  }
  CCAnimation *animation = CCAnimation::createWithSpriteFrames(arr, 0.1);
  CCAnimate * ac = CCAnimate::create(animation);
  //actions_[string(actionname)] = ac;
  //ac->retain();
  return ac;
}
